package cn.edu.ctbu.demo1.aspect;

import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect
@Slf4j
public class HttpAspect {
    @Pointcut("execution(* cn.edu.ctbu.demo1.webapi.StudentRestController.*(..))")
    public void log(){

    }
    /**
     * 在log执行之前
     */
    @Before("log()")
    public void doBefore(){
        System.out.println("准备开始执行list...");
    }

    /**
     * 在log执行之后
     */
    @After("log()")
    public void doAfter(){
        System.out.println("执行list完,准备返回...");
    }

    @AfterReturning(returning = "object",pointcut = "log()")
    public void afterR(Object object){
        log.info("response={}",object);
    }
}
